import { ref } from 'vue'
import { useRouter } from 'vue-router'

export default function () {
  // 搜索关键词
  const condition = ref<string>('')
  // 路由实例
  const router = useRouter()

  // 搜索跳转
  const search = () => {
    // 跳转到新的标签页（'/search'）
    const url = router.resolve({
      path: '/search',
      query: {
        condition: condition.value,
      },
    })
    window.open(url.href, '_blank')
  }

  return { condition, search }
}
